﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace AdatbazisProjekt
{
    class Utils
    {     public static void szamlaPrint(string nrord,string nrfact,string termek,
            string ar,string vasarlo,string cnp,string cim,
            string bank,string bankszamla,string regcom,string datum)
        {
            string text = "############################################## "+System.Environment.NewLine+
                "Nr de ordine:" + nrord + "    " + "Nr.Factura:" + nrfact + System.Environment.NewLine +
                "Termek:" + termek + "    " + "Ar:" + ar + System.Environment.NewLine +
                "Vasarlo:" + vasarlo + System.Environment.NewLine +
                "CNP:" + cnp + System.Environment.NewLine +
                "Cim:" + cim + System.Environment.NewLine +
                "Bank:" + bank + "    " + "Bank Szamla:" + bankszamla + System.Environment.NewLine +
                "Reg.com:" + regcom + System.Environment.NewLine +
                "Datum:"+datum+System.Environment.NewLine+
                "##############################################\n";
            string file="C:/szamla/"+nrfact;
            System.IO.File.WriteAllText(file+".txt", text);

          //  CreateBitmap();
            writeImage(text, file);
        }
        
        public static void writeImage(string wtext,string file) {
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(600, 400); 

            Font font = new Font("Arial", 20, FontStyle.Italic, GraphicsUnit.Pixel);
            
            for (int x = 0; x < bitmap.Height; ++x)
                for (int y = 0; y < bitmap.Width; ++y)
                    bitmap.SetPixel(y, x, System.Drawing.Color.White);
            Color color = Color.Black;
            Point atpoint = new Point(bitmap.Width / 2, bitmap.Height / 2);
            SolidBrush brush = new SolidBrush(color);
            Graphics graphics = Graphics.FromImage(bitmap);

            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
         
            graphics.DrawString(wtext, font, brush, atpoint, sf);
            graphics.Dispose();
            bitmap.Save(file+".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            Szamla s = new Szamla();

            s.pictureBox1.Image = bitmap;
        }
 
    }

  
}
